//-----------------------------------------------------------------------------
//	File: task_init.c
//	Author: xialing
//		a task for init
//-----------------------------------------------------------------------------

#include "task_init.h"

// task prio & stk & id
#define TASK_PRIO	100
OS_TID task_init_id;

static 	uint8_t e2dat;
static MguiConf_TypeDef conf;

//-----------------------------------------------------------------------------
//	task_init - a task for init
//-----------------------------------------------------------------------------
__task void task_init(void)
{
	configure_i2c_eeprom_gpio();
	ssd1306_init();
	mgui_init(&conf);

	while (1) {
		// first run check
		eeprom_read(EEPROM_KEY_ADDR, &e2dat);
		if (e2dat == EEPROM_KEY_DEF) {
			;
		}
		else {
			eeprom_write(EEPROM_KEY_ADDR, EEPROM_KEY_DEF);
		}

		os_tsk_delete_self();
	}
}

//-----------------------------------------------------------------------------
//	task_init_create - task create for init
//-----------------------------------------------------------------------------
void task_init_create(void)
{
	task_init_id = os_tsk_create(task_init, TASK_PRIO);
}

